import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SubscribeMsgVO, SubscribeMsgForm, SubscribeMsgQuery } from '@/api/infra/subscribeMsg/types';

/**
 * 查询订阅消息列表
 * @param query
 * @returns {*}
 */

export const listSubscribeMsg = (query?: SubscribeMsgQuery): AxiosPromise<SubscribeMsgVO[]> => {
  return request({
    url: '/infra/subscribeMsg/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询订阅消息详细
 * @param subscribeMsgId
 */
export const getSubscribeMsg = (subscribeMsgId: string | number): AxiosPromise<SubscribeMsgVO> => {
  return request({
    url: '/infra/subscribeMsg/' + subscribeMsgId,
    method: 'get'
  });
};

/**
 * 新增订阅消息
 * @param data
 */
export const addSubscribeMsg = (data: SubscribeMsgForm) => {
  return request({
    url: '/infra/subscribeMsg',
    method: 'post',
    data: data
  });
};

/**
 * 修改订阅消息
 * @param data
 */
export const updateSubscribeMsg = (data: SubscribeMsgForm) => {
  return request({
    url: '/infra/subscribeMsg',
    method: 'put',
    data: data
  });
};

/**
 * 删除订阅消息
 * @param subscribeMsgId
 */
export const delSubscribeMsg = (subscribeMsgId: string | number | Array<string | number>) => {
  return request({
    url: '/infra/subscribeMsg/' + subscribeMsgId,
    method: 'delete'
  });
};
